//
//  DKValue.m
//  DanaKreditLoan
//
//  Created by ZhengChengFeng on 2024/10/18.
//

#import "DKValue.h"

static NSNumberFormatter *__sharedNumberFormatter = nil;

@implementation DKValue

+ (void)load{
    @autoreleasepool {
        static dispatch_once_t onceToken;
        dispatch_once(&onceToken, ^{
            __sharedNumberFormatter = [[NSNumberFormatter alloc] init];
        });
    }
}

@end

NSString *esString(id obj) {
    NSString *str = @"";
    ESStringVal(&str, obj);
    return str;
}

BOOL ESStringVal(NSString **var, id obj){
    if (obj && (NSNull *)obj != [NSNull null]) {
        if ([obj isKindOfClass:[NSString class]]) {
            *var = obj;
            return YES;
        }
        else if ([obj isKindOfClass:[NSNumber class]]) {
            *var = [obj stringValue];
            return YES;
        }
        else if([obj isKindOfClass:[NSObject class]]){
            *var = [obj description];
            return YES;
        }
    }
    return NO;
}

BOOL isDictionary(id obj){
    if(obj&&[obj isKindOfClass:[NSDictionary class]])
        return YES;
    else
        return NO;
}

BOOL isArray(id obj){
    if(obj&&[obj isKindOfClass:[NSArray class]])
        return YES;
    else
        return NO;
}




